<?php
$q=$_GET["q"];
$cs=explode(",",$q);
$Anal_in=$cs[1];
$Anal_val=$cs[0];
$hint="";
if(strlen($q)>0&&$q!="0")
{
include_once ("../Login/databaseconnection.php");
$arr="";
$getque = mysql_query("SELECT DISTINCT ".$Anal_in." FROM school");
if($getque)
{
while($row= mysql_fetch_array($getque))
{
$Anal_in_value=$row[$Anal_in];
$value=substr($Anal_in_value,0,strlen($Anal_val));
if(strcasecmp($value,$Anal_val)==0)
{
if(empty($arr))
{
$arr=$Anal_in_value;
}
else
{
$arr=$arr.",".$Anal_in_value;
}
}
}
}
 $array= explode(",",$arr);
if(count($array)>5)
{
   $hint=$hint.'<div style="height:145px; overflow-Y:scroll; ">';
}
for ($i = 0; $i <count($array); $i++) {
 $temp =$array[$i];
  if($temp!="")
  {
  $hint=$hint.'<li onClick="fill(\''.$temp.'\');">'.$temp.'</li>';
  }
  $j = $i;
  for ($k = 0; $k <count($array); $k++) 
  {
    if ($k != $j) {
      if ($temp == $array[$k]) 
	  {
        $array[$k]="";
      }
    }
  }
}
if(count($array)>5)
{
$hint=$hint.'</div>';
}
}
if($hint=="")
{
$response="No suggestions";
}
else
{
$response=$hint;
}
echo $response;
?>